package map;

import java.util.Observable;
import java.util.Observer;

import networkedmodules.Module;
import networkedmodules.ModuleGroup;

public class MapModule extends Module implements Observer
{
    protected Map map;
    
    public MapModule(Map m)
    {
        map = m;
        map.addObserver(this);
    }
    
    public void requestMap()
    {
        if(group.getType() == ModuleGroup.CLIENT)
            group.sendUpdate(new NewMapUserUpdate(this.getKey()));
    }

    public void fullMapUpdate()
    {
        this.getModuleGroup().sendUpdate(new FullMapUpdate(this.getKey(), map.data));
    }

    public void update(Observable arg0, Object arg1)
    {
        if(arg1.equals(FullMapUpdate.class))
            fullMapUpdate();
    }
}
